<?php
/**
 * Created by PhpStorm.
 * User: yangyou
 * Date: 2018/12/4 0004
 * Time: 14:50
 */
/**
 * Author:Jack Wang
 * Time:2018-10-19 14:05:13
 * Describe:判断文件是否存在
 * @param $file
 * @return bool
 */
 function checkFileExists($file){
    // 远程文件
    if(strtolower(substr($file, 0, 4))=='http'){
        $header = get_headers($file, true);
        return isset($header[0]) && (strpos($header[0], '200') || strpos($header[0], '304'));
        // 本地文件
    }else{
        return file_exists($file);
    }
}

//[]字符串分割成数组
function StrToArray($substations){
    if(!empty($substations)) {
        $substations = str_replace("[", '', $substations);//替换所有的[
        $substations = rtrim($substations, "]");//去掉最后一个]
        $substations = explode("]", $substations);//分割成数组
    }
    return !empty($substations) ? $substations : [];
}